package com.hejjon.schedule;

import com.hejjon.dao.IXStudentRepository;
import com.hejjon.entity.XStudent;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;
import java.util.UUID;

/**
 *  要执行的任务业务逻辑
 * Created by caoshi at 6:43 2021-08-22
 */
public class SaveStudent implements Job {

    @Autowired
    private IXStudentRepository studentRepository;

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        XStudent student = new XStudent();
        String uuid = UUID.randomUUID().toString();
        student.setId(uuid);
        student.setName("testname_" + uuid.charAt(0));
        student.setAge(12);
        student.setEmail("testemail_" + uuid.charAt(1));
        student.setPhone("32423123");
        student.setCreateTime(new Date());
        student.setUpdateTime(new Date());
        studentRepository.save(student);
    }
}
